SeSAMe implements inference of sex, age, ethnicity. These are valuable information for checking the integrity of the experiment and detecting sample swaps.
Sex is inferred based on our curated X-linked probes and Y chromosome probes excluding pseudo-autosomal regions and XCI escapes.
Human:
sdf = sesameDataGet('EPIC.1.SigDF')
inferSex(sdf)## [1] "MALE"
inferSexKaryotypes(sdf)## [1] "XaY"
Mouse:
sdf = sesameDataGet("MM285.1.SigDF")
inferSex(sdf)## [1] Male
## Levels: Female Male
Ethnicity is inferred using a random forest model trained based on
both the built-in SNPs (rs probes) and channel-switching
Type-I probes.
sdf = sesameDataGet('EPIC.1.SigDF')
inferEthnicity(sdf)## [1] "WHITE"
SeSAMe provides age regression a la the well-known Horvath 353 model (see Horvath 2013)
betas <- sesameDataGet('HM450.1.TCGA.PAAD')$betas
predictAgeHorvath353(betas)## [1] 84.13913
SeSAMe provides age estimation using a set of 347 CpGs (see Zhou et al. 2022)
library(SummarizedExperiment)
betas = assay(sesameDataGet("MM285.10.SE.tissue"))The age of the mouse can be predicted using the
predictMouseAgeInMonth function. This looks for overlapping
probes and estimates age using an aging model built from 347 MM285
probes. The function returns a numeric output of age in months. The
model is most accurate with SeSAMe preprocessing. Here’s an example.
predictMouseAgeInMonth(betas[,1])## [1] 1.413134
This indicates thaat this mouse is approximately 1.41 months old.
SeSAMe estimates leukocyte fraction using a two-component model.This function works for samples whose targeted cell-of-origin is not related to white blood cells.
betas.tissue <- sesameDataGet('HM450.1.TCGA.PAAD')$betas
estimateLeukocyte(betas.tissue)## [1] 0.2007592
The goal of data sanitization is to modifiy IDAT files in place, so they can be released to public domain without privacy leak. This will be achieved by deIdentification.
Let’s take DNA methylation data from the HM450 platform for example.
tmp = tempdir()
res_grn = sesameAnno_get("Test/3999492009_R01C01_Grn.idat", dest_dir=tmp)
res_red = sesameAnno_get("Test/3999492009_R01C01_Red.idat", dest_dir=tmp)This first method of deIdentification masks SNP probe intensity mean by zero. As a consequence, the allele frequency will be 0.5.
deIdentify(res_grn$dest_file, sprintf("%s/deidentified_Grn.idat", tmp))
deIdentify(res_red$dest_file, sprintf("%s/deidentified_Red.idat", tmp))
betas1 = getBetas(readIDATpair(sprintf("%s/Test/3999492009_R01C01", tmp)))
betas2 = getBetas(readIDATpair(sprintf("%s/deidentified", tmp)))
head(betas1[grep('rs',names(betas1))])
head(betas2[grep('rs',names(betas2))])Note that before deIdentify, the rs values will all be different. After deIdentify, the rs values will all be masked at an intensity of 0.5.
This second method of deIdentification will scramble the intensities using a secret key to help formalize a random number. Therefore, randomize needs to be set to TRUE.
my_secret <- 13412084
set.seed(my_secret)
deIdentify(res_grn$dest_file,
sprintf("%s/deidentified_Grn.idat", tmp), randomize=TRUE)
my_secret <- 13412084
set.seed(my_secret)
deIdentify(res_red$dest_file,
sprintf("%s/deidentified_Red.idat", tmp), randomize=TRUE)
betas1 = getBetas(readIDATpair(sprintf("%s/Test/3999492009_R01C01", tmp)))
betas2 = getBetas(readIDATpair(sprintf("%s/deidentified", tmp)))
head(betas1[grep('rs',names(betas1))])
head(betas2[grep('rs',names(betas2))]) Note that the rs values are scrambled after deIdentify.
To restore order of the deIdentified intensities, one can re-identify IDATs. The reIdentify function can thus restore the scrambled SNP intensities.
my_secret <- 13412084
set.seed(my_secret)
reIdentify(sprintf("%s/deidentified_Grn.idat", tmp),
sprintf("%s/reidentified_Grn.idat", tmp))
my_secret <- 13412084
set.seed(my_secret)
reIdentify(sprintf("%s/deidentified_Red.idat", tmp),
sprintf("%s/reidentified_Red.idat", tmp))
betas1 = getBetas(readIDATpair(sprintf("%s/Test/3999492009_R01C01", tmp)))
betas2 = getBetas(readIDATpair(sprintf("%s/reidentified", tmp)))
head(betas1[grep('rs',names(betas1))])
head(betas2[grep('rs',names(betas2))]) Note that reIdentify restored the values. Subsequently, they are the same as betas1.
sessionInfo()## R version 4.2.0 (2022-04-22)
## Platform: aarch64-apple-darwin21.5.0 (64-bit)
## Running under: macOS Monterey 12.4
##
## Matrix products: default
## BLAS: /Users/zhouw3/.Renv/versions/4.2.0/lib/R/lib/libRblas.dylib
## LAPACK: /Users/zhouw3/.Renv/versions/4.2.0/lib/R/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats4 stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] SummarizedExperiment_1.26.1 Biobase_2.56.0
## [3] GenomicRanges_1.48.0 GenomeInfoDb_1.32.2
## [5] IRanges_2.30.0 S4Vectors_0.34.0
## [7] MatrixGenerics_1.8.0 matrixStats_0.62.0
## [9] sesame_1.15.3 sesameData_1.14.0
## [11] ExperimentHub_2.4.0 AnnotationHub_3.4.0
## [13] BiocFileCache_2.4.0 dbplyr_2.2.0
## [15] BiocGenerics_0.42.0 rmarkdown_2.14
## [17] R6_2.5.1
##
## loaded via a namespace (and not attached):
## [1] bitops_1.0-7 bit64_4.0.5
## [3] filelock_1.0.2 RColorBrewer_1.1-3
## [5] httr_1.4.3 tools_4.2.0
## [7] bslib_0.3.1 utf8_1.2.2
## [9] DBI_1.1.3 colorspace_2.0-3
## [11] tidyselect_1.1.2 preprocessCore_1.58.0
## [13] bit_4.0.4 curl_4.3.2
## [15] compiler_4.2.0 cli_3.3.0
## [17] DelayedArray_0.22.0 sass_0.4.1
## [19] scales_1.2.0 randomForest_4.7-1.1
## [21] readr_2.1.2 proxy_0.4-27
## [23] rappdirs_0.3.3 stringr_1.4.0
## [25] digest_0.6.29 XVector_0.36.0
## [27] pkgconfig_2.0.3 htmltools_0.5.2
## [29] fastmap_1.1.0 rlang_1.0.2
## [31] RSQLite_2.2.14 shiny_1.7.1
## [33] jquerylib_0.1.4 generics_0.1.2
## [35] jsonlite_1.8.0 wheatmap_0.2.0
## [37] BiocParallel_1.30.3 dplyr_1.0.9
## [39] RCurl_1.98-1.7 magrittr_2.0.3
## [41] GenomeInfoDbData_1.2.8 Matrix_1.4-1
## [43] Rcpp_1.0.8.3 munsell_0.5.0
## [45] fansi_1.0.3 lifecycle_1.0.1
## [47] stringi_1.7.6 yaml_2.3.5
## [49] MASS_7.3-57 zlibbioc_1.42.0
## [51] plyr_1.8.7 grid_4.2.0
## [53] blob_1.2.3 parallel_4.2.0
## [55] promises_1.2.0.1 crayon_1.5.1
## [57] lattice_0.20-45 Biostrings_2.64.0
## [59] hms_1.1.1 KEGGREST_1.36.2
## [61] knitr_1.39 pillar_1.7.0
## [63] reshape2_1.4.4 codetools_0.2-18
## [65] glue_1.6.2 BiocVersion_3.15.2
## [67] evaluate_0.15 BiocManager_1.30.18
## [69] png_0.1-7 vctrs_0.4.1
## [71] tzdb_0.3.0 httpuv_1.6.5
## [73] gtable_0.3.0 purrr_0.3.4
## [75] assertthat_0.2.1 cachem_1.0.6
## [77] ggplot2_3.3.6 xfun_0.31
## [79] mime_0.12 xtable_1.8-4
## [81] e1071_1.7-11 later_1.3.0
## [83] class_7.3-20 tibble_3.1.7
## [85] AnnotationDbi_1.58.0 memoise_2.0.1
## [87] ellipsis_0.3.2 interactiveDisplayBase_1.34.0
## [89] BiocStyle_2.24.0